Hi,
I am a beginner in writing makefiles. I am having some problem compiling an application using Makefile.
I have two directories, that are at the same level.
1: TEST, in which resides the application that I have written,
2: PROJECT_DIRECTORY, is an existing project with a nested directory structure.
my Makefile resides in TEST.
my application needs to access some functions defined in a file called M_Example.h. M_Example.c and M_Example.h both reside in
Code:
PROJECT_DIRECTORY/some_dir_1/some_dir_2/some_dir_3/some_dir_4
Now, independently of TEST, I can compile PROJECT_DIRECTORY successfully and the compilation process generates .o files and .a files. My understanding is that these are the libraries at each level and could be used as such in the Makefile. For example, after compilation, I have at the location
Code:
PROJECT_DIRECTORY/some_dir_1/some_dir_2/some_dir_3/some_dir_4
So, here is how my makefile looks
Code:
APP_PATH=./
INCLUDE_PATH=./
PROJECT_CORE_PATH=../PROJECT_DIRECTORY/some_dir_1/some_dir_2/some_dir_3/some_dir_4
PROJECT_INCLUDE_PATH = $(PROJECT_CORE_PATH)
WARNINGS = -Wall
APP_SOURCES=$(wildcard $(APP_PATH)/*.c)
APP_HEADERS=$(wildcard $(APP_PATH)/*.h)
PROJECT_LIBS=$(wildcard $(PROJECT_CORE_PATH)/*.o)
PROJECT_HEADERS=$(wildcard $(PROJECT_CORE_PATH)/*.h)
vpath %.c $(APP_SOURCES)
vpath %.h $(APP_HEADERS) $(PROJECT_HEADERS)
vpath %.o $(PROJECT_LIBS)
all : hello
hello : my_string_help.o
my_string_help.o : my_string_help.c $(APP_HEADERS) $(PROJECT_HEADERS) $(PROJECT_LIBS)
gcc -c my_string_help.c
clean:
rm -f my_string_help.o hello
This is very basic file, my_string_help.c resides in folder TEST, and uses a function from PROJECT_DIRECTORY. I just need to make sure that it can link without errors, but I get the following error when I run "make".
gcc -c my_string_help.c
my_string_help.c:2:22: error: M_Example.h: No such file or directory
make: *** [my_string_help.o] Error 1
thanks,